package com.lwc.controller;

import com.lwc.bean.GodownEntry;
import com.lwc.bean.GodownEntryDetails;
import com.lwc.bean.GodownEntryQuery;
import com.lwc.bean.MaterialStockQuery;
import com.lwc.common.bean.PageBean;
import com.lwc.common.bean.ResultBean;
import com.lwc.common.controller.BaseController;
import com.lwc.service.GodownEntryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
@Api(tags = "入库查询")
public class GodownEntryController  extends BaseController {

    @Autowired
    GodownEntryService godownEntryService;

    @ApiOperation("筛选查询")
    @PostMapping("/query1")
    public ResultBean query(@RequestBody GodownEntryQuery GodownEntryQuery) {
        PageBean pageBean = godownEntryService.query(GodownEntryQuery);
        return success("查询成功", pageBean);
    }

    @ApiOperation("通过单号id查询入库详情")
    @GetMapping("/getqueryById")
    public ResultBean getqueryById(int id) {
        List<GodownEntryDetails> list = godownEntryService.getqueryById(id);
        return success("查询入库详情成功", list);
    }

    @ApiOperation("入库审核同意")
    @GetMapping("/getupdateById")
    public ResultBean getupdatetrue(@RequestParam(required = true) int id) {
        int rs = godownEntryService.getupdatetrue(id);
        return rs>0?success("更改成功"):fail("更改失败");
    }

    @ApiOperation("入库审核不同意")
    @GetMapping("/getupdateflaseById")
    public ResultBean getupdateflaseById(@RequestParam(required = true) int id,String reason) {
        int rs = godownEntryService.getupdateflaseById(id,reason);
        return rs>0?success("更改成功"):fail("更改失败");
    }


}